Python Requests Essentials by Chandra Rakesh Vidya; Varanasi Bala Subrahmanyam

Python Requests Essentials by Chandra Rakesh Vidya; Varanasi Bala Subrahmanyam

Author:Chandra, Rakesh Vidya; Varanasi, Bala Subrahmanyam
Language: eng
Format: epub, pdf
Publisher: Packt Publishing


Creating an authentication Request

If we remember the theme of the third chapter, we learned different kinds of authentication with requests, such as Basic authentication, Digest authentication, and OAuth authentication. Time to apply all that stuff in real time!

Now, we will be using OAuth1 authentication to get the access to the Twitter API. In the first step of obtaining a key, we got access to Consumer key, Consumer secret, Access token and Access token secret, now we should use them to authenticate our application. The following commands show how we can accomplish the process:

>>> import requests >>> from requests_oauthlib import OAuth1 >>> CONSUMER_KEY = 'YOUR_APP_CONSUMER_KEY' >>> CONSUMER_SECRET = 'YOUR_APP_CONSUMER_SECRET' >>> ACCESS_TOKEN = 'YOUR_APP_ACCESS_TOKEN' >>> ACCESS_TOKEN_SECRET = 'YOUR_APP_ACCESS_TOKEN_SECRET' >>> auth = OAuth1(CONSUMER_KEY, CONSUMER_SECRET, ... ACCESS_TOKEN, ACCESS_TOKEN_SECRET)



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.